package com.example.administrator.myphoto.utils;

import android.content.Context;
import android.os.Build;
import android.os.Environment;

import java.io.File;

/**
 * Created by liuZhi
 * 2015/10/24
 */
public class FileUtils {
    public static File getRootCache(Context context){
        File rootFile=null;
        if (Build.VERSION.SDK_INT>Build.VERSION_CODES.BASE_1_1){
            rootFile=context.getExternalCacheDir();
        }else {
            if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
                rootFile=new File(Environment.getExternalStorageDirectory()+File.separator+AppConfig.ROOT_CACHE);
            }else {
                rootFile=new File(Environment.getDataDirectory()+File.separator+context.getPackageName());
            }
            if (!rootFile.exists()){
                rootFile.mkdirs();
            }
        }
        return rootFile;
    }
}
